<template>
  <div>
    <el-button @click="$router.back()">返回</el-button>
    <el-descriptions class="descriptions">
      <el-descriptions-item label="订单编号：">
        {{ form.orderId }}
      </el-descriptions-item>
      <el-descriptions-item label="运单编号：">
        {{ form.order.transportOrder?.id }}
      </el-descriptions-item>
      <el-descriptions-item label="下单时间：">
        {{ form.order.createTime }}
      </el-descriptions-item>
      <el-descriptions-item label="订单状态：">{{ form.order.orderType===2?'已签收':'未签收' }}</el-descriptions-item>
      <el-descriptions-item label="预计到达日期：">
        {{ form.order.estimatedArrivalTime }}
      </el-descriptions-item>
    </el-descriptions>
    <el-collapse class="collapse">
      <el-collapse-item title="基本信息" class="jiben">
        <el-row>
          <el-col> <i class="el-icon-s-flag"></i><span>发货方</span> </el-col>
          <el-col :span="5">
            <div>
              发货方姓名
              <span>
                {{ form.order.senderName }}
              </span>
            </div>
            <div>
              发货方地址：
              <span>
                {{ form.order.senderProvince?.name
                }}{{ form.order.senderCity?.name
                }}{{ form.order.senderCounty?.name }}
              </span>
            </div>
          </el-col>
          <el-col :span="5">
            <div>
              发货方电话
              <span>
                {{ form.order.senderPhone }}
              </span>
            </div>
            <div>
              详细地址
              <span>{{ form.order.senderAddress }}</span>
            </div>
          </el-col>
          <el-col> <i class="el-icon-s-flag"></i><span>收货方</span> </el-col>
          <el-col :span="5">
            <div>
              收货方姓名
              <span>
                {{ form.order.receiverName }}
              </span>
            </div>
            <div>
              收货方地址
              <span>
                {{ form.order.receiverProvince?.name
                }}{{ form.order.receiverCity?.name
                }}{{ form.order.receiverCounty?.name }}
              </span>
            </div>
          </el-col>
          <el-col :span="5">
            <div>
              收货方电话：
              <span>
                {{ form.order.receiverPhone }}
              </span>
            </div>
            <div>
              详细地址
              <span>
                {{ form.order.receiverAddress }}
              </span>
            </div>
          </el-col>
        </el-row>
      </el-collapse-item>
      <el-collapse-item title="运输信息">
        <div class="pick-info" style="padding: 25px 44px 0">
          <el-steps
            finish-status="success"
            :space="300"
            align-center
            style="margin-left: -100px"
          >
            <el-step
              v-for="item in lineList"
              :key="item.bid"
              :title="item.name"
            />
          </el-steps>
          <div class="description">
            <div class="item" v-for="item in taskTransportsList" :key="item?.id">
              <div class="label">运输任务:</div>
              <div class="content" style="color: #419eff">{{ item?.id }}</div>
              <div class="label">车辆:</div>
              <div class="content">{{ item.truck.licensePlate }}</div>
              <div class="label">司机:</div>
              <div class="content">
                <span v-for="(drive, index) in item.drivers" :key="drive?.id"
                  >{{ drive?.name
                  }}{{ item.drivers.length === index + 1 ? "" : "," }}</span
                >
              </div>
              <div class="label">到达时间:</div>
              <div class="content">{{ item.actualArrivalTime }}</div>
            </div>
          </div>
        </div>
      </el-collapse-item>
      <el-collapse-item title="货品信息">
        <el-table :data="tableData" border style="width: 100%">
          <el-table-column label="序号" type="index"> </el-table-column>
          <el-table-column prop="name" label="货品名称"> </el-table-column>
          <el-table-column prop="goodsType.name" label="货品类型">
          </el-table-column>
          <el-table-column prop="weight" label="重量（千克）">
          </el-table-column>
          <el-table-column prop="volume" label="体积（立方）">
          </el-table-column>
        </el-table>
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
import { getwillApi } from "@/api/waybill";
export default {
  name: "waybillDetail",
  data() {
    return {
      form: {
        order: {
          orderId: "",
        },
      },
      tableData: [{}],
      lineList: [],
      taskTransportsList: [],
    };
  },
  created() {
    this.waybill();
  },
  methods: {
    //获取运单详情
    async waybill() {
      console.log(this.$route.query.id);
      const res = await getwillApi(this.$route.query.id);
      console.log(res);
      this.form = res.data;
      this.lineList = JSON.parse(res.data.transportLine).nodeList;
      console.log(this.lineList);
      this.taskTransportsList = res.data.taskTransports;
      console.log(this.taskTransportsList);
      this.tableData = res.data.order.orderCargoDTOS;
      console.log(res.data);
    },
  },
};
</script>

<style lang="scss" scoped>
.descriptions {
  width: 100%;
  height: 108px;
  background-color: #fff;
  padding: 25px 44px;
}
.collapse {
  .el-collapse-item {
    margin-top: 40px;
    .el-collapse-item__header {
      font-size: 16px;
      padding: 20px;
      height: 60px;
      font-weight: 700;
    }
    .el-collapse-item__wrap {
      padding: 24px 44px;
    }
  }
  .jiben {
    i {
      font-size: 14px;
      color: blue;
    }
    span {
      font-size: 16px;
      margin-left: 10px;
    }
  }
  .el-col.el-col-6 {
    font-size: 14px;
    margin-top: 10px;
  }
}
</style>